// #define print(...)
//  哈希映射解法
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> tmp;
        for(int i=0; i<nums.size();i++){
            if(tmp.count(target - nums[i]))
                return {tmp[target-nums[i]], i};
            tmp[nums[i]] = i;
        }
        return vector<int>();
    }
};

/* // golang
func twoSum(nums []int, target int) []int {
    tmp := make(map[int]int, len(nums))
    for i, v := range nums {
        if t, ok := tmp[target-v]; ok {
            return []int{t, i}
        } else {
            tmp[v] = i
        }
    }
    return nil
}
*/
